

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <sys/queue.h>

#include <rte_memory.h>
#include <rte_launch.h>
#include <rte_eal.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_debug.h>

int lcore_hello(__rte_unused void *arg)
{
    unsigned lcore_id;
    lcore_id = rte_lcore_id();
    printf("hello from core %u\n", lcore_id);
    return 0;
}

int main(int argc, char *argv[])
{
    int ret = rte_eal_init(argc, argv);
    if (ret < 0)
        rte_panic("rte_eal_init failed\n");

    // 子lcore执行lcore_hello
    unsigned lcore_id;
    for (int lcore_id = rte_get_next_lcore(-1, 1, 0); lcore_id < RTE_MAX_LCORE; lcore_id = rte_get_next_lcore(lcore_id, 1, 0))
    {
        rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
    }

    rte_eal_cleanup();

    return 0;
}